package org.geektimes.web.mvc.initializer;

import javax.servlet.ServletContext;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.geektimes.configuration.microprofile.config.sources.servlet.ServletContextConfigSource;

public class MyWebConfigurationApplicationInitializer implements ApplicationInitializer {

	public final static String CONFIG_NAME = "my_web_config";

	@Override
	public void onStartup(ServletContext servletContext) {

		Config config = ConfigProviderResolver.instance().getBuilder().addDefaultSources()
				.withSources(new ServletContextConfigSource(servletContext))
				.addDiscoveredConverters()
				.addDiscoveredConverters().build();

		servletContext.setAttribute(CONFIG_NAME, config);
	}

	@Override
	public int getOrder() {
		return 200;
		
	}
}